package Commandes;

import java.awt.image.BufferedImage;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;
import projetjava.ApercuPhotoGrand;


public class Commande_Flouter implements Commande{
    

 private ApercuPhotoGrand apg;
     
    public Commande_Flouter(ApercuPhotoGrand apg) {
        
        this.apg=apg;

    }

    public boolean executer() {
    
        this.flouter();
        return false;
    }

    public boolean cancel() {
    
        return false;
    }
    
    
        public void flouter(){
         
        BufferedImage apercu = this.apg.getApercu();    
        int w = apercu.getWidth();
        int h = apercu.getHeight();
        BufferedImage dimg = dimg = new BufferedImage(w, h,BufferedImage.TYPE_INT_ARGB);
        float[] flou = {1f/9f,1f/9f,1f/9f,1f/9f,1f/9f,1f/9f,1f/9f,1f/9f,1f/9f};
        Kernel kernel = new Kernel(3,3,flou);
        ConvolveOp cop = new ConvolveOp(kernel,ConvolveOp.EDGE_ZERO_FILL,null);
        cop.filter(apercu,dimg);
        this.apg.setApercu(dimg);

    }
}
